//头部信息
app.controller('Header', function($scope, $http, $location, $timeout, common){
    //变量声明
    $scope.userInfo     = new Object();

    //数据加载
    $scope.load_data    = function(){
        var url     = config.prefix_url+'/Public/getUserInfo';
        $http.get(url).success(function(info){
            if(info.code != 1){
                common.dealError(info);
                return false;
            }
            $scope.userInfo     = info.data.info;
            if($scope.userInfo.nickname.length > 7){
                $scope.userInfo.nickname    = $scope.userInfo.nickname.substr(0, 7)+'...';
            }
        });
    }

    //退出登录
    $scope.logout   = function(){
        var url     = config.prefix_url+'/Public/logout';
        $http.get(url).success(function(info){
            if(info.code != 1){
                common.dealError(info);
                return false;
            }
            window.open('./login.html', '_self');
        });
    }

    //全屏
    $scope.full_screen  = function(){
        var WsShell = new ActiveXObject('WScript.Shell')
        WsShell.SendKeys('{F11}');
    }

    $scope.load_data();
});

//菜单栏导航控制
app.controller('Menu', function($scope, $http, $rootScope, $location, $timeout, common){

    //加载菜单
    common.loadMenu();

    $scope.collapse     = function(index){
        $('.s-list-group').collapse('hide');
        $('.s-list-group').eq(index).collapse('show');
    };

    $scope.open     = function(url){
        $('.s-list-group > .list-group-item').each(function(){
            if($(this).data('url') == url){
                $(this).addClass('active');
            }else{
                $(this).removeClass('active');
            }
        });

        common.openUrl(url);
    };
});
